import { App } from 'vue'

import { formatUtcString } from '@/utils/date-format'
import type { IAlertInfo } from '@/utils/type'
import { ToastUtil } from '@/utils/toast'

export default function registerProperties(app: App) {
  //1:给全局增加$alert函数
  app.config.globalProperties.$alert = (info: IAlertInfo): Promise<boolean> => {
    return ToastUtil.alert(info)
  }

  //2:给全局增加$filters过滤器
  app.config.globalProperties.$filters = {
    formatTime(value: string) {
      return formatUtcString(value)
    }
  }
}
